package temp.dao;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import temp.po.Test;
@Repository("userDao") 
public class UserDaoImpl implements UserDao {
	
	@PersistenceContext 
	 private EntityManager em; 
	@Transactional
	public Test save(Test accountInfo) {
		// try {
//		Properties props = new Properties();
//		props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
//		props.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver"); 
//		props.setProperty("hibernate.connection.url", "jdbc:mysql://127.0.0.1:3306/wuyo?useUnicode=true&amp;characterEncoding=GBK");
//		props.setProperty("hibernate.connection.username", "root" );  
//		props.setProperty("hibernate.connection.password", "bobolnear" );   
//		
		
//		EntityManagerFactory emf = Persistence.createEntityManagerFactory(
//				"wuyo_jpaPU");
//		EntityManager em = emf.createEntityManager();
//		em.getTransaction().begin();
//		// EntityManagerHelper.beginTransaction();
//
//		em.persist(accountInfo);
//		em.getTransaction().commit();
//		emf.close();
		// } catch (Exception e) {
		// // TODO: handle exception
		// }
		em.persist(accountInfo);
		return accountInfo;
	}
}
